WPS Office.apk(点击下载) / TemplatePreviewFragment.java


package cn.wps.moffice.foreigntemplate.fragment;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.Loader;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Patterns;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.AbsListView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import cn.wps.moffice.OfficeApp;
import cn.wps.moffice.foreigntemplate.bean.EnTemplateBean;
import cn.wps.moffice.foreigntemplate.bean.UrlBean;
import cn.wps.moffice.foreigntemplate.widget.ForeignTemplatePreviewView;
import cn.wps.moffice.main.common.ServerParamsUtil;
import cn.wps.moffice.main.framework.BaseTitleActivity;
import cn.wps.moffice.main.push.explore.PushTipsWebActivity;
import cn.wps.moffice.main.push.read.PushReadWebActivity;
import cn.wps.moffice_eng.R;
import com.facebook.ads.AudienceNetworkActivity;
import com.google.gson.reflect.TypeToken;
import com.mopub.mobileads.VastExtensionXmlManager;
import defpackage.fau;
import defpackage.fbx;
import defpackage.fcn;
import defpackage.lwd;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;

public class TemplatePreviewFragment extends Fragment implements View.OnClickListener {
    private boolean cSD = false;
    private int dLp = 1;
    private View dWq;
    private String efE;
    private boolean fAA = false;
    private int fAB = -1;
    private LinearLayout fAr;
    private fcn fAs;
    private fce fAt;
    private View fAu;
    private ListView fAv;
    private fau fAw;
    public ForeignTemplatePreviewView fAx;
    private View fAy;
    private fbx fAz;
    private EnTemplateBean fwJ = null;
    private int fxD = -1;
    private boolean fyc = false;
    private View mContentView;
    private Activity mContext;
    private LoaderManager mLoaderManager;

    class a implements LoaderManager.LoaderCallbacks<UrlBean> {
        private a() {
        }

        /* synthetic */ a(TemplatePreviewFragment templatePreviewFragment, byte b) {
            this();
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final Loader<UrlBean> onCreateLoader(int i, Bundle bundle) {
            TemplatePreviewFragment.a(TemplatePreviewFragment.this, true);
            return fbv.btv().aF(TemplatePreviewFragment.this.getActivity(), TemplatePreviewFragment.this.fwJ.id);
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.content.Loader, java.lang.Object] */
        @Override // android.app.LoaderManager.LoaderCallbacks
        public final /* synthetic */ void onLoadFinished(Loader<UrlBean> loader, UrlBean urlBean) {
            UrlBean urlBean2 = urlBean;
            if (TemplatePreviewFragment.a((Fragment) TemplatePreviewFragment.this)) {
                TemplatePreviewFragment.a(TemplatePreviewFragment.this, false);
                if (urlBean2 != null && !TextUtils.isEmpty(urlBean2.url)) {
                    try {
                        fcd.a(TemplatePreviewFragment.this.getActivity(), TemplatePreviewFragment.this.fwJ, URLDecoder.decode(urlBean2.url, AudienceNetworkActivity.WEBVIEW_ENCODING), new lwd.b() {
                            /* class cn.wps.moffice.foreigntemplate.fragment.TemplatePreviewFragment.a.AnonymousClass1 */

                            @Override // defpackage.lwd.b, defpackage.lwd.a
                            public final void km(boolean z) {
                                super.km(z);
                                fcd.g(TemplatePreviewFragment.this.mContext, TemplatePreviewFragment.this.fwJ.id, TemplatePreviewFragment.this.fwJ.name, TemplatePreviewFragment.this.fwJ.format);
                                TemplatePreviewFragment.this.mContext.onBackPressed();
                                if (TemplatePreviewFragment.this.fAz != null) {
                                    String bE = ebo.bE(OfficeApp.arx());
                                    fbx fbx = TemplatePreviewFragment.this.fAz;
                                    String str = TemplatePreviewFragment.this.fwJ.id;
                                    if (fbx.mActivity != null && fbx.fAY.isChecked()) {
                                        String btw = fbx.btw();
                                        if (!TextUtils.isEmpty(btw)) {
                                            new fbx.a(bE, str, btw).execute(new Void[0]);
                                        }
                                    }
                                }
                            }
                        });
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final void onLoaderReset(Loader<UrlBean> loader) {
        }
    }

    /* access modifiers changed from: package-private */
    public class b implements LoaderManager.LoaderCallbacks<ArrayList<EnTemplateBean>> {
        private int wt;

        public b(int i) {
            this.wt = i;
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final Loader<ArrayList<EnTemplateBean>> onCreateLoader(int i, Bundle bundle) {
            TemplatePreviewFragment.b(TemplatePreviewFragment.this, true);
            fbv btv = fbv.btv();
            Activity activity = TemplatePreviewFragment.this.mContext;
            String str = TemplatePreviewFragment.this.fwJ.id;
            int i2 = this.wt;
            hwe hwe = new hwe();
            hwe.dk("tid", str);
            hwe.dk("start", String.valueOf(i2));
            hwe.dk("limit", "6");
            fbv.a(activity, hwe, true);
            return new lof(activity).Lr(0).HX("http://api.docer.4wps.net/template/similar-like").b(new TypeToken<ArrayList<EnTemplateBean>>() {
                /* class defpackage.fbv.AnonymousClass16 */
            }.getType()).u(hwe.cmr());
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.content.Loader, java.lang.Object] */
        @Override // android.app.LoaderManager.LoaderCallbacks
        public final /* synthetic */ void onLoadFinished(Loader<ArrayList<EnTemplateBean>> loader, ArrayList<EnTemplateBean> arrayList) {
            ArrayList<EnTemplateBean> arrayList2 = arrayList;
            if (TemplatePreviewFragment.a((Fragment) TemplatePreviewFragment.this)) {
                if (this.wt != 0 || (arrayList2 != null && arrayList2.size() >= 2)) {
                    TemplatePreviewFragment.a(TemplatePreviewFragment.this, arrayList2);
                } else {
                    TemplatePreviewFragment.o(TemplatePreviewFragment.this);
                    TemplatePreviewFragment.this.fAA = true;
                }
                TemplatePreviewFragment.b(TemplatePreviewFragment.this, false);
            }
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final void onLoaderReset(Loader<ArrayList<EnTemplateBean>> loader) {
        }
    }

    class c implements LoaderManager.LoaderCallbacks<EnTemplateBean> {
        c() {
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final Loader<EnTemplateBean> onCreateLoader(int i, Bundle bundle) {
            TemplatePreviewFragment.a(TemplatePreviewFragment.this, true);
            return fbv.btv().aG(TemplatePreviewFragment.this.mContext, String.valueOf(TemplatePreviewFragment.this.efE));
        }

        /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.content.Loader, java.lang.Object] */
        @Override // android.app.LoaderManager.LoaderCallbacks
        public final /* synthetic */ void onLoadFinished(Loader<EnTemplateBean> loader, EnTemplateBean enTemplateBean) {
            EnTemplateBean enTemplateBean2 = enTemplateBean;
            if (TemplatePreviewFragment.a((Fragment) TemplatePreviewFragment.this) && enTemplateBean2 != null) {
                TemplatePreviewFragment.this.fwJ = enTemplateBean2;
                TemplatePreviewFragment.a(TemplatePreviewFragment.this, false);
                TemplatePreviewFragment.c(TemplatePreviewFragment.this);
                TemplatePreviewFragment.d(TemplatePreviewFragment.this);
                TemplatePreviewFragment.e(TemplatePreviewFragment.this);
                TemplatePreviewFragment.f(TemplatePreviewFragment.this);
                TemplatePreviewFragment.g(TemplatePreviewFragment.this);
                TemplatePreviewFragment.this.fAt.a(enTemplateBean2);
            }
        }

        @Override // android.app.LoaderManager.LoaderCallbacks
        public final void onLoaderReset(Loader<EnTemplateBean> loader) {
        }
    }

    static /* synthetic */ void a(TemplatePreviewFragment templatePreviewFragment, ArrayList arrayList) {
        boolean z = true;
        if (arrayList == null || arrayList.isEmpty()) {
            templatePreviewFragment.fAA = true;
            if (templatePreviewFragment.fAw.btj() != 0 || arrayList == null || arrayList.isEmpty()) {
                z = false;
            }
            templatePreviewFragment.fyc = z;
        } else {
            if (templatePreviewFragment.fAw.btj() != 0 || arrayList.isEmpty()) {
                z = false;
            }
            templatePreviewFragment.fyc = z;
            fau fau = templatePreviewFragment.fAw;
            fau.fyc = templatePreviewFragment.fyc;
            if (arrayList != null && !arrayList.isEmpty()) {
                fau.axC.addAll(arrayList);
                fau.notifyDataSetChanged();
            }
            templatePreviewFragment.fAA = false;
        }
        templatePreviewFragment.cSD = false;
    }

    static /* synthetic */ void a(TemplatePreviewFragment templatePreviewFragment, final boolean z) {
        templatePreviewFragment.mContext.runOnUiThread(new Runnable() {
            /* class cn.wps.moffice.foreigntemplate.fragment.TemplatePreviewFragment.AnonymousClass5 */

            public final void run() {
                if (TemplatePreviewFragment.this.dWq != null) {
                    if (z) {
                        TemplatePreviewFragment.this.dWq.setVisibility(0);
                    } else {
                        TemplatePreviewFragment.this.dWq.setVisibility(8);
                    }
                }
            }
        });
    }

    public static boolean a(Fragment fragment) {
        return !fragment.isRemoving() && fragment.getActivity() != null && !fragment.isDetached() && fragment.isAdded() && fragment.getView() != null;
    }

    public static TemplatePreviewFragment b(int i, int i2, String str, String str2) {
        TemplatePreviewFragment templatePreviewFragment = new TemplatePreviewFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("start_form", i);
        bundle.putInt("start_function", i2);
        bundle.putString("template_id", str);
        bundle.putString("position", str2);
        templatePreviewFragment.setArguments(bundle);
        return templatePreviewFragment;
    }

    static /* synthetic */ void b(TemplatePreviewFragment templatePreviewFragment, boolean z) {
        if (templatePreviewFragment.fAy == null) {
            templatePreviewFragment.fAy = LayoutInflater.from(templatePreviewFragment.mContext).inflate(R.layout.listview_loading_view, (ViewGroup) templatePreviewFragment.fAv, false);
        }
        if (z) {
            if (templatePreviewFragment.fAv != null && templatePreviewFragment.fAv.getFooterViewsCount() == 0) {
                templatePreviewFragment.fAv.addFooterView(templatePreviewFragment.fAy);
            }
        } else if (templatePreviewFragment.fAv != null && templatePreviewFragment.fAv.getFooterViewsCount() > 0) {
            templatePreviewFragment.fAv.removeFooterView(templatePreviewFragment.fAy);
        }
    }

    private String btr() {
        String pI;
        return (this.fxD == -1 || (pI = fcb.pI(this.fwJ.format)) == null) ? "public" : pI;
    }

    private boolean bts() {
        return this.fxD == 1 || this.fxD == 2 || this.fxD == 3;
    }

    static /* synthetic */ void c(TemplatePreviewFragment templatePreviewFragment) {
        if (templatePreviewFragment.fwJ != null && templatePreviewFragment.fwJ.intro_images != null && templatePreviewFragment.fwJ.status == faq.fxS) {
            templatePreviewFragment.fAx = new ForeignTemplatePreviewView(templatePreviewFragment.mContext, ((BaseTitleActivity) templatePreviewFragment.mContext).getRootViewGroup(), "word".equalsIgnoreCase(templatePreviewFragment.fwJ.format) ? 1 : "excel".equalsIgnoreCase(templatePreviewFragment.fwJ.format) ? 2 : "ppt".equalsIgnoreCase(templatePreviewFragment.fwJ.format) ? 3 : 0, String.valueOf(templatePreviewFragment.hashCode()));
            templatePreviewFragment.fAx.setThumbnailData(templatePreviewFragment.fwJ);
            templatePreviewFragment.fAv.addHeaderView(templatePreviewFragment.fAx);
        }
    }

    private void cp(Context context) {
        this.mContext = getActivity();
        this.fAt = (fce) context;
    }

    static /* synthetic */ void d(TemplatePreviewFragment templatePreviewFragment) {
        fcn.a aVar;
        if (templatePreviewFragment.fAs == null) {
            templatePreviewFragment.fAs = new fcn(templatePreviewFragment.mContext, "word".equalsIgnoreCase(templatePreviewFragment.fwJ.format) ? 1 : "excel".equalsIgnoreCase(templatePreviewFragment.fwJ.format) ? 2 : "ppt".equalsIgnoreCase(templatePreviewFragment.fwJ.format) ? 3 : 0, templatePreviewFragment.btr());
        }
        fcn fcn = templatePreviewFragment.fAs;
        if (ServerParamsUtil.tH("en_template_preview_recommend_ad") && cvn.hy("en_template_preview_recommend_ad")) {
            ServerParamsUtil.Params tG = fvd.tG("en_template_preview_recommend_ad");
            if (tG == null || !fvd.tH("en_template_preview_recommend_ad")) {
                aVar = null;
            } else if (tG.extras == null) {
                aVar = null;
            } else {
                aVar = new fcn.a((byte) 0);
                for (ServerParamsUtil.Extras extras : tG.extras) {
                    if (!TextUtils.isEmpty(extras.key) && !TextUtils.isEmpty(extras.value)) {
                        if ("text".equals(extras.key)) {
                            aVar.text = extras.value;
                            fcn.fCK = extras.value;
                        }
                        if ("desc".equals(extras.key)) {
                            aVar.desc = extras.value;
                        }
                        if ("pic_url".equals(extras.key)) {
                            aVar.cyu = extras.value;
                        }
                        if ("link".equals(extras.key)) {
                            aVar.link = extras.value;
                        }
                        if ("jump_type".equals(extras.key)) {
                            aVar.jumpType = extras.value;
                        }
                    }
                }
            }
            if (aVar != null && !TextUtils.isEmpty(aVar.text) && !TextUtils.isEmpty(aVar.link)) {
                String qv = dty.qv(fcn.cBX);
                if (!TextUtils.isEmpty(qv)) {
                    fcn.s(qv + "_templates_activity_show", qv + "_templates_activity_click", aVar.text);
                }
                View inflate = LayoutInflater.from(fcn.mContext).inflate(R.layout.public_foreign_template_detail_inner_ad_layout, (ViewGroup) null);
                fcn.mRootView = inflate.findViewById(R.id.template_inner_ad_container);
                fcn.mRootView.setOnClickListener(new View.OnClickListener(aVar) {
                    /* class defpackage.fcn.AnonymousClass1 */
                    final /* synthetic */ a fCM;

                    {
                        this.fCM = r2;
                    }

                    public final void onClick(View view) {
                        if (!TextUtils.isEmpty(this.fCM.link)) {
                            fbq.U(String.format("%s_templates_operation_click", fcn.this.fCL), fcn.this.fCK);
                            if ("readwebview".equals(this.fCM.jumpType)) {
                                Intent intent = new Intent(fcn.this.mRootView.getContext(), PushReadWebActivity.class);
                                intent.setAction("android.intent.action.MAIN");
                                intent.addCategory("android.intent.category.DEFAULT");
                                intent.putExtra("bookid", true);
                                intent.putExtra("netUrl", this.fCM.link);
                                fcn.this.mRootView.getContext().startActivity(intent);
                                return;
                            }
                            Intent intent2 = new Intent(fcn.this.mRootView.getContext(), PushTipsWebActivity.class);
                            intent2.putExtra(hbe.frL, this.fCM.link);
                            fcn.this.mRootView.getContext().startActivity(intent2);
                        }
                    }
                });
                ImageView imageView = (ImageView) inflate.findViewById(R.id.inner_ad_icon);
                int gF = luf.gF(fcn.mContext) - (luf.dip2px(fcn.mContext, 16.0f) << 1);
                ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
                layoutParams.width = gF;
                layoutParams.height = (int) (0.24390243902439024d * ((double) gF));
                imageView.setLayoutParams(layoutParams);
                dry.bt(inflate.getContext()).li(aVar.cyu).A(R.drawable.internal_template_default_item_bg, false).a(imageView);
                ((TextView) inflate.findViewById(R.id.innaer_ad_title)).setText(aVar.text);
                ((TextView) inflate.findViewById(R.id.innaer_ad_desc)).setText(aVar.desc);
                fcn.mRootView.post(new Runnable() {
                    /* class defpackage.fcn.AnonymousClass2 */

                    public final void run() {
                        fcn.this.aMz();
                    }
                });
            }
        }
        View view = templatePreviewFragment.fAs.mRootView;
        if (!(view == null || templatePreviewFragment.fAv == null || templatePreviewFragment.fwJ.status != faq.fxS)) {
            templatePreviewFragment.fAv.addHeaderView(view);
            fbq.U(String.format("%s_templates_operation_show", templatePreviewFragment.btr()), templatePreviewFragment.fAs.fCK);
        }
    }

    static /* synthetic */ void e(TemplatePreviewFragment templatePreviewFragment) {
        if (templatePreviewFragment.fwJ.status != faq.fxS) {
            View inflate = View.inflate(templatePreviewFragment.mContext, R.layout.foreign_template_withdraw_layout, null);
            if (templatePreviewFragment.fAv != null) {
                templatePreviewFragment.fAv.addHeaderView(inflate);
            }
        }
    }

    static /* synthetic */ void f(TemplatePreviewFragment templatePreviewFragment) {
        if (ServerParamsUtil.tH("template_preview_recommend") && ServerParamsUtil.tG("template_preview_recommend") != null) {
            templatePreviewFragment.fAu = LayoutInflater.from(templatePreviewFragment.mContext).inflate(R.layout.foreign_template_preview_title_layout, (ViewGroup) null);
            if (templatePreviewFragment.fAv != null) {
                templatePreviewFragment.fAv.addHeaderView(templatePreviewFragment.fAu);
            }
            if (templatePreviewFragment.fAv != null) {
                templatePreviewFragment.fAv.setOnScrollListener(new AbsListView.OnScrollListener() {
                    /* class cn.wps.moffice.foreigntemplate.fragment.TemplatePreviewFragment.AnonymousClass3 */

                    public final void onScroll(AbsListView absListView, int i, int i2, int i3) {
                        if (i3 > 0 && i + i2 == i3) {
                            TemplatePreviewFragment.k(TemplatePreviewFragment.this);
                        }
                    }

                    public final void onScrollStateChanged(AbsListView absListView, int i) {
                        if (i == 2) {
                            try {
                                vzh.m252if(TemplatePreviewFragment.this.mContext);
                                vzh.fVn();
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        } else {
                            vzh.m252if(TemplatePreviewFragment.this.mContext);
                            vzh.fVm();
                        }
                    }
                });
            }
        }
    }

    static /* synthetic */ void g(TemplatePreviewFragment templatePreviewFragment) {
        if (templatePreviewFragment.fAw == null) {
            templatePreviewFragment.fAw = new fau(templatePreviewFragment.mContext, templatePreviewFragment.btr());
            templatePreviewFragment.fAw.fyf = new fau.a() {
                /* class cn.wps.moffice.foreigntemplate.fragment.TemplatePreviewFragment.AnonymousClass1 */

                @Override // defpackage.fau.a
                public final void c(EnTemplateBean enTemplateBean) {
                    if (!TextUtils.isEmpty(enTemplateBean.name)) {
                        if (fcc.z(enTemplateBean.id, enTemplateBean.name, enTemplateBean.format)) {
                            fcd.g(TemplatePreviewFragment.this.mContext, enTemplateBean.id, enTemplateBean.name, enTemplateBean.format);
                        } else if (lwd.hu(TemplatePreviewFragment.this.getActivity())) {
                            TemplatePreviewFragment.this.fAt.a(enTemplateBean, TemplatePreviewFragment.this.fxD);
                        } else {
                            lvg.d(TemplatePreviewFragment.this.getActivity(), R.string.public_network_error, 0);
                        }
                    }
                }
            };
        }
        templatePreviewFragment.fAv.setAdapter((ListAdapter) templatePreviewFragment.fAw);
        if (templatePreviewFragment.fwJ != null) {
            templatePreviewFragment.fAr.setVisibility(templatePreviewFragment.fwJ.status == faq.fxS ? 0 : 8);
            fbq.x("templates_overseas_%s_0_preview", templatePreviewFragment.fwJ.tags, templatePreviewFragment.bts() ? fcb.pI(templatePreviewFragment.fwJ.format) : null);
            fby.a(templatePreviewFragment.fwJ, templatePreviewFragment.btr() + "_template_%d_preview");
            if (templatePreviewFragment.dLp == 1 || templatePreviewFragment.dLp == 3) {
                fcy.p(new Runnable() {
                    /* class cn.wps.moffice.foreigntemplate.fragment.TemplatePreviewFragment.AnonymousClass2 */

                    public final void run() {
                        try {
                            lwd.d("https://movip.wps.com/template/v1/template/view", "tid=" + TemplatePreviewFragment.this.fwJ.id, null);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                });
            }
        }
    }

    static /* synthetic */ void k(TemplatePreviewFragment templatePreviewFragment) {
        if (lwd.hx(templatePreviewFragment.mContext) && !templatePreviewFragment.fAA && !templatePreviewFragment.cSD) {
            int i = -1;
            if (templatePreviewFragment.fAw != null) {
                templatePreviewFragment.fAB++;
                i = templatePreviewFragment.fAB * 6;
            }
            if (templatePreviewFragment.mLoaderManager != null) {
                templatePreviewFragment.cSD = true;
                templatePreviewFragment.mLoaderManager.restartLoader(2336, null, new b(i));
            }
        }
    }

    static /* synthetic */ void o(TemplatePreviewFragment templatePreviewFragment) {
        if (templatePreviewFragment.fAv != null) {
            templatePreviewFragment.fAv.removeHeaderView(templatePreviewFragment.fAu);
        }
    }

    @Override // android.app.Fragment
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        cp(activity);
    }

    @Override // android.app.Fragment
    @TargetApi(23)
    public void onAttach(Context context) {
        super.onAttach(context);
        cp(context);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.preview_use /*{ENCODED_INT: 2131367034}*/:
                if (lwd.hx(this.mContext) && this.fwJ != null) {
                    if (fcc.z(this.fwJ.id, this.fwJ.name, this.fwJ.format)) {
                        fcd.g(this.mContext, this.fwJ.id, this.fwJ.name, this.fwJ.format);
                    } else {
                        if (!ebo.arU()) {
                            fpp.rX("2");
                        }
                        ebo.b(this.mContext, new Runnable() {
                            /* class cn.wps.moffice.foreigntemplate.fragment.TemplatePreviewFragment.AnonymousClass4 */

                            public final void run() {
                                if (ebo.arU()) {
                                    TemplatePreviewFragment.this.mLoaderManager.restartLoader(2327, null, new a(TemplatePreviewFragment.this, (byte) 0));
                                }
                            }
                        });
                        fbq.x("templates_overseas_%s_0_use", this.fwJ.tags, bts() ? fcb.pI(this.fwJ.format) : null);
                    }
                    fby.a(this.fwJ, btr() + "_template_%d_use");
                    if (fcd.d(this.fwJ)) {
                        fbk.e("templates_overseas_bling_1_use", this.fwJ.id);
                    }
                    HashMap hashMap = new HashMap();
                    if ("ppt".equalsIgnoreCase(this.fwJ.format)) {
                        hashMap.put(VastExtensionXmlManager.TYPE, "ppt");
                    } else if ("word".equalsIgnoreCase(this.fwJ.format)) {
                        hashMap.put(VastExtensionXmlManager.TYPE, "doc");
                    } else if ("excel".equalsIgnoreCase(this.fwJ.format)) {
                        hashMap.put(VastExtensionXmlManager.TYPE, "sheet");
                    } else {
                        hashMap.put(VastExtensionXmlManager.TYPE, "other");
                    }
                    djq.l("feature_template_apply", hashMap);
                    return;
                }
                return;
            default:
                return;
        }
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        if (this.mContentView == null) {
            if (getArguments() != null) {
                this.dLp = getArguments().getInt("start_form", 1);
                this.fxD = getArguments().getInt("start_function", -1);
                this.efE = getArguments().getString("template_id");
            }
            this.mContentView = layoutInflater.inflate(R.layout.fragment_foreign_template_preview, viewGroup, false);
            this.fAr = (LinearLayout) this.mContentView.findViewById(R.id.bottom_bar);
            ((TextView) this.mContentView.findViewById(R.id.preview_use)).setOnClickListener(this);
            this.dWq = this.mContentView.findViewById(R.id.progress_bar);
            this.fAv = (ListView) this.mContentView.findViewById(R.id.preview_refresh_list_view);
            ViewStub viewStub = (ViewStub) this.mContentView.findViewById(R.id.stub_send_email_layout);
            this.fAz = new fbx();
            fbx fbx = this.fAz;
            Activity activity = this.mContext;
            if (ServerParamsUtil.tH("send_template_to_mail")) {
                fbx.mActivity = activity;
                View inflate = viewStub.inflate();
                fbx.fAY = (CheckBox) inflate.findViewById(R.id.checkbox);
                fbx.fAZ = (TextView) inflate.findViewById(R.id.message);
                fbx.fBa = inflate.findViewById(R.id.edit_mail_address);
                fbx.fBb = inflate.findViewById(R.id.add_mail_address);
                fbx.AnonymousClass1 r0 = new View.OnClickListener() {
                    /* class defpackage.fbx.AnonymousClass1 */

                    public final void onClick(View view) {
                        fbx fbx = fbx.this;
                        czq czq = new czq(fbx.mActivity);
                        czq.setTitleById(R.string.public_edit_email_address);
                        EditText editText = new EditText(fbx.mActivity);
                        editText.setHint(R.string.public_enter_email_address);
                        String btw = fbx.btw();
                        if (!TextUtils.isEmpty(btw)) {
                            editText.setText(btw);
                            editText.setSelection(btw.length());
                        }
                        czq.setView(editText);
                        czq.setPositiveButton(R.string.public_done, new DialogInterface.OnClickListener(editText) {
                            /* class defpackage.fbx.AnonymousClass3 */
                            final /* synthetic */ EditText fBe;

                            {
                                this.fBe = r2;
                            }

                            public final void onClick(DialogInterface dialogInterface, int i) {
                                String obj = this.fBe.getText().toString();
                                fbx fbx = fbx.this;
                                if (!TextUtils.isEmpty(obj) && Patterns.EMAIL_ADDRESS.matcher(obj).matches()) {
                                    fbx fbx2 = fbx.this;
                                    jaa.bH(OfficeApp.arx(), "config_send_template_mail").edit().putString("address", obj).apply();
                                    dialogInterface.dismiss();
                                    fbx.this.updateViewState();
                                    fbx.this.kn(false);
                                    dwp.lV("public_template_editmail_done");
                                    return;
                                }
                                lvg.d(fbx.this.mActivity, R.string.public_enter_correct_email_address, 0);
                            }
                        });
                        czq.setNegativeButton(R.string.public_cancel, new DialogInterface.OnClickListener() {
                            /* class defpackage.fbx.AnonymousClass4 */

                            public final void onClick(DialogInterface dialogInterface, int i) {
                                dialogInterface.dismiss();
                            }
                        });
                        czq.setCanAutoDismiss(false);
                        czq.show();
                        editText.postDelayed(new Runnable(editText) {
                            /* class defpackage.fbx.AnonymousClass5 */
                            final /* synthetic */ EditText fBe;

                            {
                                this.fBe = r2;
                            }

                            public final void run() {
                                this.fBe.requestFocus();
                                luf.cj(this.fBe);
                            }
                        }, 100);
                        dwp.lV("public_template_editmail_show");
                        if (fbx.this.fBa == view) {
                            dwp.lV("public_template_sendmailhint_edit");
                        } else if (fbx.this.fBb == view) {
                            dwp.lV("public_template_addmailhint_add");
                        }
                    }
                };
                fbx.fBa.setOnClickListener(r0);
                fbx.fBb.setOnClickListener(r0);
                fbx.fAY.setChecked(true);
                fbx.fAY.setOnClickListener(new View.OnClickListener() {
                    /* class defpackage.fbx.AnonymousClass2 */

                    public final void onClick(View view) {
                        dwp.lV("public_template_sendmailhint_check");
                    }
                });
                fbx.updateViewState();
            }
            ((BaseTitleActivity) this.mContext).getRootViewGroup().addView(LayoutInflater.from(this.mContext).inflate(R.layout.foreign_preview_float_page_layout, (ViewGroup) null));
            this.mLoaderManager = getLoaderManager();
            this.mLoaderManager.restartLoader(2328, null, new c());
        }
        return this.mContentView;
    }

    public void onDestroy() {
        super.onDestroy();
        if (this.mLoaderManager != null) {
            this.mLoaderManager.destroyLoader(2327);
            this.mLoaderManager.destroyLoader(2328);
            this.mLoaderManager.destroyLoader(2336);
        }
        if (this.fAx != null) {
            ForeignTemplatePreviewView foreignTemplatePreviewView = this.fAx;
            if (foreignTemplatePreviewView.efZ != null) {
                foreignTemplatePreviewView.efZ.setImagesNull();
            }
            foreignTemplatePreviewView.efU = null;
            foreignTemplatePreviewView.efW = null;
            foreignTemplatePreviewView.efX = null;
            foreignTemplatePreviewView.efZ = null;
        }
        this.fAv = null;
        this.fAx = null;
        vzh.m252if(this.mContext).Xy("template_pre_activity" + hashCode());
    }

    public void onResume() {
        super.onResume();
        this.cSD = false;
        if (this.fAz != null) {
            this.fAz.kn(true);
        }
    }
}